﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace ks
{
    public class 桥梁
    {
        public static DataTable ExecuteDataTable(string sql)
        {
            string connectionString = @"server=DESKTOP-QCMGQJO\MSSQLSERVER3;database=Music;integrated security=true";
            SqlConnection con = new SqlConnection();
            con.ConnectionString = connectionString;

            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = sql;
            DataTable table = new DataTable();
            SqlDataAdapter dapt = new SqlDataAdapter(cmd);
            dapt.Fill(table);
            con.Close();
            return table;


        }
        public static int ExecuteNonQuery(string sql)
        {
            string connectionString = @"server=DESKTOP-QCMGQJO\MSSQLSERVER3;database=Music;integrated security=true";
            SqlConnection con = new SqlConnection();
            con.ConnectionString = connectionString;
            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = sql;
            int ret = cmd.ExecuteNonQuery();
            con.Close();
            return ret;
        }
    }
}